package zz.util;

import java.sql.*;

public class DBUtil {
//    Connection conn = null;
    public static Connection getConnection() throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");

//        Connection connection = null;
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/user?useUnicode=true&characterEncoding=UTF-8&userSSL=false&serverTimezone=GMT%2B8","root","123456");
        System.out.println("创建连接成功");

        return connection;
    }
    public static void closeAll(ResultSet resultSet,Statement statement,Connection connection) throws SQLException {
        if (resultSet!=null){
            statement.close();
        }
        if (connection!=null){
            connection.close();
        }
        if (statement!=null){
            statement.close();
        }
    }
}
